/*  
 *  Copyright 2006 Paul Jack.
 *
 *  This file is part of the Dex compiler suite. 
 *  
 *  Dex is free software; you can redistribute it and/or modify it
 *  under the terms of the GNU General Public License as published by the
 *  Free Software Foundation; either version 2 of the License, or (at your
 *  option) any later version.
 *  
 *  Dex is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
 *  Public License for more details.
 *  
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
 */
package dex.compiler.model.definition;


import java.util.List;

import dex.compiler.model.base.ParseNode;
import dex.compiler.model.base.Place;
import dex.compiler.model.expression.Expression;


/**
 * A macro invocation.
 */
public class Macro extends ParseNode {

	
	/**
	 * The name of the macro being invoked.
	 */
	private String name;
	
	
	/**
	 * The parameters to send to that macro.
	 */
	private List<Expression> parameters;
	
	
	/**
	 * Constructs a new macro invocation.
	 * 
	 * @param place  the place where the macro invocation originated
	 * @param name   the name of the macro being invoked
	 * @param parameters   the parameters for that macro
	 */
	public Macro(Place place, String name, List<Expression> parameters) {
		super(place);
		this.name = name;
		this.parameters = parameters;
	}


	/**
	 * Returns the name of the macro being invoked.
	 *
	 * @return  the name
	 */
	public String getName() {
		return name;
	}


	/**
	 * Returns the parameters for the macro.
	 *
	 * @return  the parameters
	 */
	public List<Expression> getParameters() {
		return parameters;
	}

	
	@Override
	public String toString() {
		StringBuilder result = new StringBuilder();
		result.append("macro ").append(name).append('(');
		result.append(Expression.listToString(parameters));
		result.append(")\n");
		return result.toString();
	}


}
